﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MyLibary.DAL;
namespace MyLibary.BIZ
{
    public class BIZ_NguoiDung
    {
        #region Fields
        public string TaiKhoan { get; set; }
        public string Ten { get; set; }
        public string MatKhau { get; set; }
        public string DiaChi { get; set; }
        public string SDT { get; set; }
        public int Quyen { get; set; }
        #endregion
        #region Contructor
        public BIZ_NguoiDung() { }
        public BIZ_NguoiDung(string TaiKhoan, string Ten, string MatKhau, string DiaChi, string SDT, int Quyen)
        {
            this.TaiKhoan = TaiKhoan;
            this.Ten = Ten;
            this.MatKhau = MatKhau;
            this.DiaChi = DiaChi;
            this.SDT = SDT;
            this.Quyen = Quyen;
        }
        #endregion
        #region Metholds
        public static List<BIZ_NguoiDung> GetAll()
        {
            return DAL_NguoiDung.GetAll();
        }
        public static BIZ_NguoiDung getUser(string TaiKhoan)
        {
            return DAL_NguoiDung.GetUser(TaiKhoan);
        }
        public static BIZ_NguoiDung getUser(string taiKhoan,string matKhau)
        {
            return DAL_NguoiDung.GetUser(taiKhoan, matKhau);
        }
        public bool Add()
        {
            return DAL_NguoiDung.Insert(this);
        }
        public bool Update()
        {
            return DAL_NguoiDung.Update(this);
        }
        public bool Delete()
        {
            return DAL_NguoiDung.Delete(this);
        }
        #endregion
    }
    public class IEQualityCompareNguoiDung : IEqualityComparer<BIZ_NguoiDung>
    {
        #region IEQualityCompareNguoiDung
        public bool Equals(BIZ_NguoiDung x, BIZ_NguoiDung y) { return x.TaiKhoan == y.TaiKhoan; }
        public int GetHashCode(BIZ_NguoiDung Object) { return Object.GetHashCode(); }
        #endregion
    }
}